﻿using ST.Library.UI.NodeEditor;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Drawing;

namespace STNode_A2B.STNodeControls
{
    public class STNodeControl_Label : STNodeControl
    {
        private string _editorText = ""; // 默认文本

        public String EditorText
        {
            get { return _editorText; }
            set
            {
                _editorText = value;
                Invalidate(); // 通知控件需要重新绘制
            }
        }

        protected override void OnPaint(DrawingTools dt)
        {
            //base.OnPaint(dt);

            Graphics g = dt.Graphics;
            SolidBrush brush = dt.SolidBrush;

            // 清空客户区域
            //g.Clear(this.BackColor);
            
            // 设置文本颜色
            brush.Color = this.ForeColor;

            // 设置文本的字体和对齐方式
            Font font = this.Font;
            StringFormat format = this.m_sf;
            //StringFormat format = new StringFormat();
            format.Alignment = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;

            // 绘制文本
            g.DrawString(_editorText, font, brush, this.ClientRectangle, format);
        }

        
    }
}

